<?php
//include_once '../App.conf.php';
//include_once 'common.lib.php';
require_once 'ShopExRuntime.class.php';

//  set_error_handler(_error_handler);
//  set_exception_handler(_exception_handler);



$usesandbox = false;
if ($usesandbox)
{
	$taobao_toke = array ('app_key' => '123456', 'app_secret' => 'abcdefg','host_url'=>'http://localhost/shopex/' );
}
else
{
	$taobao_toke = array ('app_key' => '123456', 'app_secret' => 'abcdefg','host_url'=>'http://localhost/shopex/' );
}

$runtime = new ShopExRuntime ( $taobao_toke );
$runtime->setRunInSandBox ( $usesandbox );

$methodname = $_REQUEST ['action'];
$methodname = 'testrefundsList';

if (function_exists ( $methodname ))
{
	$methodname ();
	exit ();
}
else
{
	$error = '找不到action：' . $methodname;
	//	log_error($error.', '.__FILE__);
//	show_error($error);
}

function writeDeliverySend()
{
	global $runtime;
	print_r($runtime->writeDeliverySend ('20100906094332','XXXX')); //alipublic01'
}

function testUser()
{
	global $runtime;
	$user = new ShopExUser ();
	$runtime->readUser ( $user, 'plmkz520',4); //alipublic01'
	print_r($user);exit; 
//	show_view ( 'printobj.tpl', array ('obj' => $user ) );
}

function testrefundsList()
{
	global $runtime;
	$result = new ShopExRefundList();

	$runtime->readRefundsReceive ( $result);

	print_r($result);
	
	show_view ( 'printobj.tpl', array ('obj' => $users ) );
}

function testUserList()
{
	global $runtime;
	$users = new ShopExUserSearchResultList();
	$param=new ShopExUserSearchParam();
	$param->page_no=1;
	$param->page_size=3;
	
	$runtime->readUserslist ( $users,$param);

	print_r($users);exit;
	
	show_view ( 'printobj.tpl', array ('obj' => $users ) );
}
function testTradesSold()
{
	global $runtime;
	$tradesResult = new ShopExTradesResult ();
	$tradesParam = new ShopExTradesParam ();
	//$tradesParam->status = 'WAIT_SELLER_SEND_GOODS';
	$tradesParam->page_size = 4;
	$tradesParam->page_no=1;
	$tradesParam->shipping='货到付款';
	
	$runtime->readTradesSold ( $tradesResult,$tradesParam );
	print_r($tradesResult);exit;
//	show_view ( 'dumpobj.tpl', array ('obj' => $tradesResult ) );
}
function testTradesSoldIncrement()
{
	global $runtime;
	$tradesResult = new TradesResult ();
	$tradesParam = new TradesParam ();
	$tradesParam->status = 'WAIT_SELLER_SEND_GOODS';
	$tradesParam->page_size = 5;
	$tradesParam->start_modified = '2010-06-04 08:00:00';
	$tradesParam->end_modified = date ( 'Y-m-d H:i:s' );
	$runtime->readTradesSoldIncrement ( $tradesResult, $tradesParam );
	show_view ( 'dumpobj.tpl', array ('obj' => $tradesResult ) );
}
function testTrade()
{
	global $runtime;
	$trade = new ShopExTrade ();
	$runtime->readTrade ( $trade, '112115096955' );
	
	print_r ( $trade );
	exit ();
	
//	show_view('dumpobj.tpl',array('obj'=>$trade));
}
function testTradeFullinfo()
{

	global $runtime;
	$trade = new ShopExTrade ();
			  		
	$runtime->readTradeFullinfo ( $trade, '20100914112098' );
	
	print_r ( $trade );
	exit ();
	
//	show_view('dumpobj.tpl',array('obj'=>$trade));
}

function testTradeClose()
{
	global $runtime;
	echo $runtime->writeTradeClose ( 112115096955, '测试关闭' );
	$trade = new Trade ();
	$runtime->readTradeFullinfo ( $trade, '112115096955' );
	var_dump ( $trade );
}

function testTradeMemoUpdate()
{
	global $runtime;
	echo $runtime->writeTradeMemoUpdate ( 112108399155, '测试更新备注1407' );
	$trade = new Trade ();
	$runtime->readTradeFullinfo ( $trade, '112108399155' );
	var_dump ( $trade );
	//echo $runtime->writeTradeMemoAdd(112111764455,'测试添加备注'); 	
}

function testAreas()
{
	global $runtime;
	$result = array ();
	$runtime->readAreas ( $result );
	show_view ( 'printobj.tpl', array ('obj' => $result ) );
}
function testLogisticsCompanies()
{
	global $runtime;
	$result = array ();
	$runtime->readLogisticsCompanies ( $result );
	show_view ( 'printobj.tpl', array ('obj' => $result ) );
}
function testLogisticsOrdersDetail()
{
	global $runtime;
	$result = new ShippingResult ();
	$param = new ShippingParam ();
	$param->end_created = '2010-06-07 12:00:00';
	$param->seller_confirm = 'yes';
	$param->status = 'ACCEPTED_BY_RECEIVER';
	$runtime->readLogisticsOrdersDetail ( $result, $param );
	show_view ( 'dumpobj.tpl', array ('obj' => $result ) );
}
function testLogisticsOrders()
{
	global $runtime;
	$result = new ShippingResult ();
	$param = new ShippingParam ();
	$param->end_created = '2010-06-07 12:00:00';
	$param->seller_confirm = 'yes';
	$param->status = 'ACCEPTED_BY_RECEIVER';
	$runtime->readLogisticsOrders ( $result, $param );
	show_view ( 'dumpobj.tpl', array ('obj' => $result ) );
}
function testItemsAll()
{
	global $runtime;
	$result = new ShopExItemSearchResultList ();
	$param = new ShopExItemSearchParam ();
	$param->page_size=20;
	$param->page_no=1;
	$param->marketable='true';
	$runtime->readItemsAll ( $result, $param );
//	show_view ( 'dumpobj.tpl', array ('obj' => $result ) );
}
function testItem()
{
	global $runtime;
	$result = new ShopExItem ();
	$runtime->readItem ( $result,  '3', true );
	print_r($result);exit;
//	show_view ( 'dumpobj.tpl', array ('obj' => $result ) );
}
function testItemDesc()
{
	global $runtime;
	$result = new TItem ();
	$runtime->readItem ( $result, '我是阿卡', NULL, '310558935', 'desc' );
	show_view ( 'dumpobj.tpl', array ('obj' => $result ) );
}
function testItemsCustom()
{
	global $runtime;
	$result = array ();
	$runtime->readItemsCustom ( $result, 'A04689', NULL, true );
	show_view ( 'dumpobj.tpl', array ('obj' => $result ) );
}
function testItemSku()
{
	global $runtime;
	$result = new Sku ();
	$runtime->readItemSku ( $result, '3248407187', '1609790361' );
	show_view ( 'dumpobj.tpl', array ('obj' => $result ) );
}
function testItemSkus()
{
	global $runtime;
	$result = array ();
	$runtime->readItemSkus ( $result, '我是阿卡', '1609790361,5189980829' );
	show_view ( 'printobj.tpl', array ('obj' => $result ) );
}
function testSkusCustom()
{
	global $runtime;
	$result = array ();
	$runtime->readSkusCustom ( $result, 'B05676' );
	show_view ( 'dumpobj.tpl', array ('obj' => $result ) );
}
//
?>